package com.example.tse.rbyair.base;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

public abstract class BaseFragment extends Fragment{
	public RbDBManager mDBManager;
	private int BACK=0;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		initDBManager();
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		
		return super.onCreateView(inflater, container, savedInstanceState);
	}
	
	private void initDBManager()	{
		mDBManager = new RbDBManager();
	}
	public void showMessageShort(String text){
		Toast.makeText(this.getActivity(), text, Toast.LENGTH_SHORT).show();
	}
	
	public void showMessageLong(String text){
		Toast.makeText(this.getActivity(), text, Toast.LENGTH_LONG).show();
	}
	
//	public void setTopText(String text){
//		((TextView)findViewById(R.id.top_text)).setText(text);
//	}
	
	private boolean backToFinish(){
		if(BACK==0){
			BACK++;
			Toast.makeText(this.getActivity(),"再按一次退出", Toast.LENGTH_SHORT).show();
			new Thread(new Runnable() {
				@Override
				public void run() {
					try {
						Thread.sleep(1500);
						BACK--;
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			}).start();
			return false;
		}else if(BACK==1){
			return true;
		}
		return true;
	}

	private class RbDBManager {
	}

//	@Override
//	public void onBackPressed() {
//		if(backToFinish())finish();
//	}
}
